// JavaScript Document
//common
$(function () {
    /*获取iframe-src的高度*/
    var dH = $(document).height();
    $(".content-page").height(dH);
    /*退出登录*/
    $(".md-trigger").bind("click", function () {
        var obj = $(this);
        var objp = obj.parents(".dropdown");
        objp.hide();
        window.location.href = "/Public/logout.html";
    });
    /* Start 头部点击展开显示*/
    $(".dropdown").bind("click", function () {
        var obj = $(this);

        if (obj.hasClass("open")) {
            obj.removeClass("open");
        } else {
            $(".dropdown").removeClass("open");
            obj.addClass("open");
        }
        /*obj=$(this).find(".dropdown-menu");
         if(obj.css("display")=="none"){
         $(".dropdown").find(".dropdown-menu").hide();
         obj.show();
         }
         else{
         obj.hide();
         }	*/
        return false;
    });
    $("html").click(function () {
        $(".dropdown").removeClass("open");
    });

    /* End 头部点击展开显示*/

    /* Start 头部menu点击变换小图标*/
    $(".open-left").bind("click", function () {
        var obj = $("#wrapper");
        var abc = $(this).parents("body");

        obj.addClass("forced");
        if (abc.hasClass("fixed-left")) {
            abc.removeClass("fixed-left").addClass("fixed-left-void");
            obj.addClass("enlarged");
            if ($("slimscrollleft").siblings(".subdrop")) {
                $(".subdrop").each(
                        function () {
                            $(this).next().hide();
                            $(this).find(".fa-angle-up").removeClass("fa-angle-up").addClass("fa-angle-down");
                            $(this).find(".icon-down-dir").removeClass("icon-down-dir").addClass("icon-right-dir");
                        }
                );
            }
            $(".fixed-left-void .enlarged .side-menu #sidebar-menu ul>li").hover(
                    function () {
                        $(".fixed-left-void .enlarged .side-menu #sidebar-menu ul>li>a").removeClass("active");
                        $(this).find("a:first").addClass("active");
                        $(this).find("ul:first").show();
                        $("this:empty").find("ul:first").hide();
                    },
                    function () {
                        $(this).find("ul:first").hide();
                    }
            );

        } else {

            abc.removeClass("fixed-left-void").addClass("fixed-left");
            obj.removeClass("enlarged");
            $(".side-menu #sidebar-menu ul > li").unbind("mouseenter").unbind("mouseleave");
        }


    });

    /* End 头部menu点击变换小图标*/

    /* Start 头部消息获取显示条数*/
    $(".absolute").each(function () {
        var rn = $(this).parents(".dropdown").find(".dropdown-menu li").length - 2;
        $(this).html(rn);
    });
    /* End 头部消息获取显示条数*/

    $("#sidebar-menu").find(".ink").remove();
    /* Start 左边菜单效果*/
    $("#sidebar-menu a").bind('click', function (e) {

        /*strart 点击圆*/
        var parent = $(this).parent();
        if (parent.find('.ink').length === 0) {
            parent.prepend('<span class="ink"></span>');
        }
        var ink = parent.find('.ink');

        var x = e.pageX - parent.offset().left - ink.width() / 2;
        var y = e.pageY - parent.offset().top - ink.height() / 2;


        ink.css({top: y + 'px', left: x + 'px'}).animate({width: 260, height: 260, left: x - 130, top: y - 130, opacity: 0.2}, 400, function () {
            ink.fadeOut(100).remove();
            setTimeout(function () {
                $(".ink").remove();
            }, 100);
        });

        /* end 点击圆*/

        /*iframe 加载页面*/
        var objiframe = $(this).attr("src");
        var objname = $(this).attr("date");
        if (!(objname == "" || objname == undefined)) {
            $(".ch_bg").html('<i class="icon-home-3"></i>' + objname);
            $(".ch_bg").next().html(objname);
        }
        iframe(objiframe);
        /*iframe 加载页面*/


        /*展开与active*/
        if (!$("#wrapper").hasClass("enlarged")) {
            if (!$(this).hasClass("subdrop")) {

                // hide any open menus and remove all other classes
                $("a", $(this).parents("ul:first")).removeClass("subdrop active");
                $("ul", $(this).parents("ul:first")).slideUp(300);
                $("#sidebar-menu .pull-right i").removeClass("fa-angle-up").addClass("fa-angle-down");


                // open our new menu and add the open class
                $(this).addClass("subdrop active");
                $(this).next("ul").slideDown(300);
                $(".pull-right i", $(this).parents(".has_sub:last")).removeClass("fa-angle-down").addClass("fa-angle-up");
                $(".pull-right i", $(this).siblings("ul")).removeClass("fa-angle-up").addClass("fa-angle-down");
                $("#sidebar-menu .has_sub>a").find(".icon-down-dir").removeClass("icon-down-dir").addClass("icon-right-dir");
                $(this).parents("ul").prev().find(".icon-right-dir").removeClass("icon-right-dir").addClass("icon-down-dir");
                $(this).find(".icon-right-dir").removeClass("icon-right-dir").addClass("icon-down-dir");

            } else if ($(this).hasClass("subdrop")) {

                $(this).removeClass("subdrop");
                $(this).next("ul").slideUp(300);
                $("a").next("ul").slideUp(300);
                $(".pull-right i").removeClass("fa-angle-up").addClass("fa-angle-down");
                $(this).find(".icon-down-dir").removeClass("icon-down-dir").addClass("icon-right-dir");
            }
        } else {
            if ($(this).hasClass("active")) {
                $(this).parents("ul").prev().addClass("active");
            }
        }
    });
    /* End 左边菜单效果结束*/

    $(".md-trigger,.clickable ").bind("click", function () {
        /*iframe 加载页面*/
        var objiframe = $(this).attr("src");
        var objname = $(this).attr("date");
        if (!(objname == "" || objname == undefined)) {
            $(".ch_bg").html('<i class="icon-home-3"></i>' + objname);
            $(".ch_bg").next().html(objname);
        }
        iframe(objiframe);
        /*iframe 加载页面*/
    });
    /* table 操作弹出提示*/
    $(".btn-group-xs .btn .fa-power-off").parent().on('click', function () {
        var obj = $(this);
        var jid = obj.data('bind');
        var post_to = obj.data('url');
        var start = obj.data("start");
        parent.layer.confirm('确定要关闭该职位？', {
            btn: ['确认', '取消'], //按钮
            title: '操作提示',
            icon: 3
        }, function () {
            $.ajax(
                    {
                        type: 'post',
                        url: post_to,
                        data: {
                            jid: jid
                        },
                        dataType: 'json',
                        success: function (data) {
                            var list = eval(data);
                            if (list.status == 1) {
                                var message = list.msg ? list.msg : '操作成功，职位已关闭！';
                                var icon = list.msg ? 0 : 1;
                                parent.layer.alert(message, {
                                    icon: icon,
                                }, function (index) {
                                    var state = obj.parents("td").prev(".job-state");
                                    if (state.length > 0) {
                                        state.find("span").removeClass("label-success").addClass("label-default").html("已关闭");
                                        var icon = obj.parents("td").find(".btn-group");
                                        icon.find(".fa-power-off").parent("a").hide();
                                        icon.find(".icon-ccw-1").parent("a").hide();
                                        icon.find(".fa-map-marker").parent("a").hide();
                                        icon.find(".fa-bullhorn").parent("a").hide();
                                        icon.find(".fa-share").parent("a").hide();
                                        icon.append('<a tit="重新发布" data-bind="{$d.jid}" class="btn btn-default" href="' + start + '"><i class="fa fa-cloud-upload"></i></a>');

                                    } else {
                                        obj.parents("tr").remove();
                                    }
                                    parent.layer.close(index);
                                });
                            } else {
                                parent.layer.alert('操作失败！请联系管理员！', {
                                    icon: 2,
                                })
                            }
                        },
                        error: function () {
                            parent.layer.msg('fail');
                        }
                    }
            );

        }
        );
    });
    /*启用弹窗*/
    $(".btn-group-xs .btn").on('click', ".fa-check-circle-o", function () {
        red_state("你确定要执行此操作吗?", $(this));
    });
    /*禁用弹窗*/
    $(".btn-group-xs .btn").on('click', ".fa-ban", function () {
        red_state("你确定要执行此操作吗?", $(this));
    });
    /*cancel 解约弹出层*/
    $(".sign-table").on("click", ".cancel", function () {
        sign("解约", $(this));
    });

    /*sign 签约弹出层*/
    $(".sign-table").on("click", ".sign", function () {
        sign("签约", $(this));
    });

    /* table 操作title提示*/
    $(".btn-group-xs").on("mouseenter", ".btn", function () {
        var that = this;
        var tit = $(this).attr("tit");
        layer.tips(tit, that, {
            tips: [1, '#68C39F'],
            time: 800
        });
    });
    /*二维码*/
    $(".table-er").click(function () {
        $(this).next().slideToggle(300);
    });

    /*评价五星选择*/
    $(".evaluate_span .fa").click(function () {
        var obj = $(this);
        if (obj.hasClass("fa-star-o")) {
            obj.parent().prevAll(".evaluate_span").find(".fa-star-o").removeClass("fa-star-o").addClass("fa-star");
            obj.removeClass("fa-star-o").addClass("fa-star");
            obj.parent().nextAll(".evaluate_span").find(".fa-star-o").removeClass("fa-star");
            var objnum = obj.parents("p").find(".fa-star").length;
            obj.parents("p").next("input").val(objnum);
        } else {
            obj.parent().prevAll(".evaluate_span").find(".fa-star").removeClass("fa-star-0").addClass("fa-star");
            obj.parent().nextAll(".evaluate_span").find(".fa-star").removeClass("fa-star").addClass("fa-star-o");
            var objnum = obj.parents("p").find(".fa-star").length;
            obj.parents("p").next("input").val(objnum);
        }
    });
    /*checkbox 全选
     $(".table th .icheckbox_square-aero").bind("click", function () {
     var obj = $(this);
     if (obj.hasClass("checked")) {
     obj.removeClass("checked");
     obj.parents(".table").find(".icheckbox_square-aero").removeClass("checked");
     obj.parents(".table").find("td input").removeAttr("checked");
     } else {
     obj.addClass("checked");
     obj.parents(".table").find(".icheckbox_square-aero").addClass("checked");
     obj.parents(".table").find("td input").prop("checked", "true");
     }
     return false;
     });
     $(".table td .icheckbox_square-aero").bind("click", function () {
     var obj = $(this);
     var checkobj = obj.parents(".table").find("th").find(".checked");
     if (obj.hasClass("checked")) {
     obj.removeClass("checked");
     obj.find("input[type='checkbox']").prop(disabled, false);
     if (checkobj) {
     checkobj.removeClass("checked");
     }
     } else {
     obj.addClass("checked");
     obj.find("input[type='checkbox']").prop(checked, true);
     var tdcheck = obj.parents(".table").find("td").find(".checked");
     var icheck = obj.parents(".table").find("td").find(".icheckbox_square-aero");
     var aero = obj.parents(".table").find("th").find(".icheckbox_square-aero");
     if (tdcheck.length == icheck.length) {
     aero.addClass("checked");
     }
     }
     return false;
     });*/
    /*读取本地文件*/
    $(".card-box").on("change", "input[type='file']", function () {
        var obj = $(this);
        if (obj.hasClass("upl_img")) {
            var url = obj.data('url'),
                    fileid = obj.attr('id'),
                    fileimg = obj.parent().find(".file-img"),
                    filefrom = obj.parent().find("input[type=hidden]"),
                    loading = obj.parent();
            $(document).ajaxStart(function () {
                loading.append("<div id='loading'></div>");
            }).ajaxComplete(function () {
                $("#loading").remove();
            });
            $.ajaxFileUpload({
                url: url, //你处理上传文件的服务端
                secureuri: false, //与页面处理代码中file相对应的ID值
                fileElementId: fileid,
                dataType: 'json', //返回数据类型:text，xml，json，html,scritp,jsonp五种
                success: function (data, status) {
                    var list = eval(data);
                    if (list.status == 0) {
                        parent.layer.msg(list.msg);
                    } else {
                        fileimg.html("");
                        fileimg.append('<img src="' + list.file_name + '" />');
                        filefrom.val(list.file_name);
                    }
                }
            });
        } else {
            var file = this.files[0];
            var reader = new FileReader();
            var image = obj.parent().find(".file-img").find("img");
            var image_1 = obj.parent().find(".file-img");
            reader.onload = function () {
                var url = reader.result;
                if (image.length > 0) {
                    image.attr("src", "");
                    setImageURL(image, url);
                } else {
                    image_1.append("<img src='" + url + "' />");
                }
            };
            reader.readAsDataURL(file);
        }
    });
    $("input[type='file']").on("change", function () {
        var obj = $(this);
        if (obj.hasClass("upl_img")) {
            var url = obj.data('url'),
                    fileid = obj.attr('id'),
                    fileimg = obj.parent().find(".file-img"),
                    filefrom = obj.parent().find("input[type=hidden]"),
                    loading = obj.parent();
            $(document).ajaxStart(function () {
                loading.append("<div id='loading'></div>");
            }).ajaxComplete(function () {
                $("#loading").remove();
            });
            $.ajaxFileUpload({
                url: url, //你处理上传文件的服务端
                secureuri: false, //与页面处理代码中file相对应的ID值
                fileElementId: fileid,
                dataType: 'json', //返回数据类型:text，xml，json，html,scritp,jsonp五种
                success: function (data, status) {
                    var list = eval(data);
                    if (list.status == 0) {
                        parent.layer.msg(list.msg);
                    } else {
                        fileimg.html("");
                        fileimg.append('<img src="' + list.file_name + '" />');
                        filefrom.val(list.file_name);
                    }
                }
            });
        } else {
            var file = this.files[0];
            var reader = new FileReader();
            var image = obj.parent().find(".file-img").find("img");
            var image_1 = obj.parent().find(".file-img");
            reader.onload = function () {
                var url = reader.result;
                if (image.length > 0) {
                    image.attr("src", "");
                    setImageURL(image, url);
                } else {
                    image_1.append("<img src='" + url + "' />");
                }
            };
            reader.readAsDataURL(file);
        }
    });

    /*城市选择*/
    $(".prov").change(function () {
        var str = $(this).val();
        $(".prov option").each(function () {
            if ($(this).attr("value") == str) {
                var obj = $(this).attr("value");
                areoajax(obj, $(".city"));
                $(".prov").next("select").show().html("").nextAll().hide();
            }
        });
    });
    $(".city").change(function () {
        var str = $(this).val();
        $(".city option").each(function () {
            if ($(this).attr("value") == str) {
                var obj = $(this).attr("value");
                areoajax(obj, $(".county"));
                $(".city").next("select").show().html("").nextAll().hide();
            }
        });
    });
    $(".county").change(function () {
        var str = $(this).val();
        $(".county option").each(function () {
            if ($(this).attr("value") == str) {
                var obj = $(this).attr("value");
                areoajax(obj, $(".street"));
                $(".county").next("select").show().html("");
            }
        });
    });
    /*城市修改*/
    if ($(".prov").length > 0) {
        var cityprov = $(".prov").data("bind");
        if (cityprov == "") {
            areoajax(0, $(".prov"));
        } else {
            areoajax(0, $(".prov"), cityprov);//省

            var city_2 = $(".city").data("bind");
            $(".city").show();
            areoajax(cityprov, $(".city"), city_2);//市

            var city_3 = $(".county").data("bind");
            $(".county").show();
            areoajax(city_2, $(".county"), city_3);//区/县
        }
    }

    /*发票修改与添加时专用发票与普通发票的选择*/
    $(".inv_special").bind("click", function () {
        $(".inv_special_box").slideDown(300);
    });
    $(".inv_normal").click(function () {
        $(".inv_special_box").slideUp(300);
    });


    //表单验证
    if ($(".demoform").length > 0) {
        var demo = $(".demoform").Validform({
            tiptype: 4,
            label: '.control-label',
            showAllError: true,
        });
        demo.addRule([
            {
                ele: ".empty",
                datatype: "*" //验证是否为空
            },
            {
                ele: ".number",
                datatype: /^\d+(\.\d{2})?$/, //验证是否为数字且小数点后只有两位
            },
            {
                ele: ".ints",
                datatype: "n", //验证是否为数字
                errormsg: "请输入整数"
            },
            {
                ele: ".chinese",
                datatype: /[\u4e00-\u9fa5]/, //验证汉字
                errormsg: "请输入汉字"
            },
            {
                ele: ".iphone",
                datatype: "m", //验证手机号
                errormsg: "请输入正确的手机号"
            },
        ]);
    }

    //头像选择
    $(".head-img img").bind("click", function () {
        var obj = $(this);
        $(".head-ture").fadeOut(300);
        obj.after('<i class="head-ture fa fa-check"></i>');
        var objval = obj.data("bind");
        $("#head-img").val(objval);
    });

    //按钮选择，值赋予隐藏域
    $("#gender span").click(function () {
        var obj = $(this);
        $("#gender span").removeClass("btn-green-1").addClass("btn-default");
        obj.removeClass("btn-default").addClass("btn-green-1");
        obj.parent().find("input").val(obj.data('bind'));

    });

    //重置密码-企业账户信息
    $(".btn-group-xs .btn").on('click', ".icon-lock-1", function () {
        var obj = $(this).parent();
        var url = obj.data("url");
        var bus_id = obj.data("bind");
        parent.layer.prompt({
            title: '修改密码',
            formType: 0, //prompt风格，支持0-2
        }, function (pass) {
            var str = /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,16}$/;
            var r = pass.match(str);
            if (6 < pass.length < 16 && r == null) {
                parent.layer.msg("重置密码失败，请输入6-16个同时包含大小写及数字的字符");
            } else {
                $.ajax({
                    type: "post",
                    url: url,
                    dataType: "json",
                    data: {
                        bus_id: bus_id,
                        pwd: pass
                    },
                    success: function (a) {
                        var list = eval(a);
                        parent.layer.msg(list.msg);
                    },
                    error: function () {
                        parent.layer.msg('fail');
                    }
                });
            }
        });
    });
});

var documentH = $(document).height();

/*file 本地获取文件*/
function setImageURL(image, url) {
    image.attr("src", url);
}
/*城市选择ajax*/
function areoajax(url, box, areoid) {
    $.ajax(
            {
                type: 'post',
                url: '/api/Area/get_childs.html?pid=' + url + '',
                crossDomain: true,
                dataType: 'jsonp',
                success: function (data) {
                    var list = eval(data);
                    if (list.status == 1) {
                        var city = list.list;
                        var cityname = box.data("name");
                        box.append('<option value=0>-请选择：' + cityname + '-</option>');
                        for (i = 0; i < city.length; i++) {
                            if (areoid == city[i].id) {
                                box.append('<option value=' + city[i].id + ' selected="selected">' + city[i].areaname + '</option>');
                            } else {
                                box.append('<option value=' + city[i].id + '>' + city[i].areaname + '</option>');
                            }
                        }
                    } else {
                        box.next("select").hide().html("");
                    }
                },
                error: function () {
                    parent.layer.msg('fail');
                }
            }
    );
}

/* Start 点击调用键盘F11全屏显示与退出*/
function toggle_fullscreen() {
    var fullscreenEnabled = document.fullscreenEnabled || document.mozFullScreenEnabled || document.webkitFullscreenEnabled;
    if (fullscreenEnabled) {
        var iframesrc = $(window.parent.document).find("#iframe-src").attr("src");
        if (!document.fullscreenElement && !document.mozFullScreenElement && !document.webkitFullscreenElement && !document.msFullscreenElement) {
            launchIntoFullscreen(document.documentElement);
            if ($("#iframe-src").attr("src") == "/Index/welcome.html") {
                $(window.parent.document).find(".content-page").height(window.screen.height);
            } else {
                $(window.parent.document).find(".content-page").height(window.screen.height);
                $(window.parent.document).find("#iframe-src").height(window.screen.height - 166);
            }
        } else {
            exitFullscreen();
            if ($("#iframe-src").attr("src") == "/Index/welcome.html") {
                $(window.parent.document).find(".content-page").height(documentH);
                $(window.parent.document).find("#iframe-src").height(documentH);
            } else {
                $(window.parent.document).find(".content-page").height(documentH);
                $(window.parent.document).find("#iframe-src").height(documentH - 166);

            }
        }
    }
}
function launchIntoFullscreen(element) {
    if (element.requestFullscreen) {
        element.requestFullscreen();
    } else if (element.mozRequestFullScreen) {
        element.mozRequestFullScreen();
    } else if (element.webkitRequestFullscreen) {
        element.webkitRequestFullscreen();
    } else if (element.msRequestFullscreen) {
        element.msRequestFullscreen();
    }
}

function exitFullscreen() {
    if (document.exitFullscreen) {
        document.exitFullscreen();
    } else if (document.mozCancelFullScreen) {
        document.mozCancelFullScreen();
    } else if (document.webkitExitFullscreen) {
        document.webkitExitFullscreen();
    }
}

/* End 点击调用键盘F11全屏显示与退出*/

/*头部点击按钮*/
function toggle_slimscroll(item) {
    if ($("#wrapper").hasClass("enlarged")) {
        $(item).css("overflow", "inherit").parent().css("overflow", "inherit");
        $(item).siblings(".slimScrollBar").css("visibility", "hidden");
    } else {
        $(item).css("overflow", "hidden").parent().css("overflow", "hidden");
        $(item).siblings(".slimScrollBar").css("visibility", "visible");
    }
}
/*兼容ie的placeholder*/
function placeholder(nodes, pcolor, ipcolor) {
    nodes.each(function () {
        var obj = $(this),
                objt = $(this).attr("placeholder");
        obj.focus(function () {
            if (obj.val() == objt || obj.val() == "") {
                obj.val("");
                obj.css("color", ipcolor)
            }
        });
        obj.blur(function () {
            if (obj.val() == "" || obj.val() == objt) {
                obj.val(objt);
                obj.css("color", pcolor);
            }
        });
        obj.val(objt);
        obj.css("color", pcolor);
    });
}

/*验空*/
function empty(empty) {
    empty.bind("blur", function () {
        var that = $(this);
        var placeholder = that.attr("placeholder");
        var leftx = that.position().left + 15,
                topy = that.position().top - 12;
        if (that.val() == "" || that.val() == placeholder) {
            that.parent().css("positon", "relative");
            that.after("<div class='valida'>不可为空<div>");
            that.next(".valida").css({"left": leftx, "top": topy + 20, "opacity": 0, "position": "absolute", "color": "#E15554", "background": "#fff"});
            that.next(".valida").animate({"left": leftx, "top": topy, "opacity": 1}, 500);
            return false;
        }
    });
    empty.bind("focus", function () {
        var that = $(this);
        var leftx = that.position().left + 15,
                topy = that.position().top;
        that.next(".valida").animate({"left": leftx, "top": topy, "opacity": 0}, 500, function () {
            that.parent().find(".valida").remove();
        });

    });
}
/*无刷新切换*/
function iframe(objiframe) {
    if (objiframe == undefined) {
    } else {
        if ($("#iframe-src").attr("src") == "") {
            $("#iframe-src").attr("src", objiframe);
            scroll()
        } else {
            $("#iframe-src").animate({"margin-left": 30, "margin-top": 30, "opacity": 0}, 300, function () {
                $("#iframe-src").removeAttr("src");
                $("#iframe-src").attr("src", objiframe).animate({"margin-left": 0, "margin-top": 0, "opacity": 1}, 300);
            });
            if (objiframe == "/Index/welcome.html") {
                $(".content-header").fadeOut(300);
                $(window.parent.document).find("#iframe-src").height(documentH);
            } else {
                $(".content-header").fadeIn(300);
                $(window.parent.document).find("#iframe-src").height(documentH - 166);
            }
            scroll();
        }
    }
}
/*滚动条在顶部*/
function scroll() {
    var x = document.body.scrollTop || document.documentElement.scrollTop;
    var timer = setInterval(function () {
        x = x - 100;
        if (x < 100) {
            x = 0;
            window.scrollTo(x, x);
            clearInterval(timer);
        }
        window.scrollTo(x, x);
    }, "0");
}
/*启用禁用*/
function red_state(test, that) {
    var obj = that.parent();
    var id = obj.data("bind");
    var post_to = obj.data("url");
    var start = obj.data("start");
    var disable = obj.data("disable");
    parent.layer.confirm(test, {
        btn: ['确认', '取消'], //按钮
        title: '操作提示',
        icon: 3
    }, function () {
        $.ajax({
            type: 'post',
            url: post_to,
            data: {
                id: id
            },
            dataType: 'json',
            success: function (data) {
                var list = eval(data);
                var objp = obj.parents("tr").find(".red-state").find("span");
                var state = obj.parents("tr").find(".vip-state").find("span");
                if (that.hasClass("fa-check-circle-o")) {//按钮为启用是，status==2 操作成功
                    if (list.status == 2) {
                        parent.layer.msg('操作成功', {
                            time: 1000 //1秒关闭（如果不配置，默认是3秒）
                        }, function () {
                            if (obj.hasClass("dospot")) {
                                obj.remove();
                                if (objp.length > 0) {
                                    objp.removeClass("label-default").addClass("label-success").html("已完成");
                                }
                            } else {
                                obj.find(".fa-check-circle-o").removeClass("fa-check-circle-o").addClass("fa-ban");
                                obj.attr("tit", "禁用");
                                obj.data("url", "" + disable + "");
                                if (state.length > 0) {
                                    state.removeClass("label-danger").addClass("label-success").html("否");
                                }
                                if (objp.length > 0) {
                                    objp.removeClass("label-default").addClass("label-success").html("已启用");
                                }
                            }
                        });
                    } else {
                        parent.layer.msg(list.msg);
                    }
                } else {
                    if (list.status == 1) {//按钮为禁用时，status==1 操作成功
                        parent.layer.msg('操作成功', {
                            time: 1000 //1秒关闭（如果不配置，默认是3秒）
                        }, function () {
                            obj.find(".fa-ban").removeClass("fa-ban").addClass("fa-check-circle-o");
                            obj.attr("tit", "启用");
                            obj.data("url", "" + start + "");
                            if (state.length > 0) {
                                state.removeClass("label-success").addClass("label-danger").html("是");
                            }
                            if (objp.length > 0) {
                                objp.removeClass("label-success").addClass("label-default").html("未启用");
                            }
                        });
                    } else {
                        parent.layer.msg(list.msg);
                    }
                }
            },
            error: function () {
                parent.layer.msg('fail');
            }
        });
    });
}
/*解约签约*/
function sign(test, that) {
    var jsid = that.data('bind');
    var post_to = that.data('url');
    var name = that.parents("tr").find("td").eq(1).text();
    parent.layer.confirm('你确定要对' + name + '，进行' + test + '吗？？', {
        btn: ['确认', '取消'], //按钮
        title: '操作提示',
        icon: 3
    }, function () {
        $.ajax({
            type: 'post',
            url: post_to,
            data: {
                jsid: jsid
            },
            dataType: 'json',
            success: function (data) {
                var list = eval(data);
                var message = list.msg ? list.msg : '操作成功，该职位已' + test + '！';
                if (that.hasClass("sign")) {
                    if (list.status == 1) {
                        parent.layer.msg(message, {time: 1000, }, function () {
                            that.data("url", "/Sign/sign_off.html");
                            that.removeClass("label-success").addClass("label-danger").html("解约");
                            that.removeClass("sign").addClass("cancel");
                            that.parent().prev(".sign-state").find("span").removeClass("label-danger").addClass("label-success").html("已签约");
                        });
                    } else {
                        parent.layer.msg(list.msg, {time: 2000, });
                    }
                } else {
                    if (list.status == 2) {
                        parent.layer.msg(message, {time: 1000, }, function () {
                            that.removeClass("label-danger").addClass("label-default").html("已解约");
                            that.parent().prev(".sign-state").find("span").removeClass("label-success").addClass("label-default").html("已解约");
                        });
                    } else {
                        parent.layer.msg(list.msg, {time: 2000, });
                    }
                }
            },
            error: function () {
                parent.layer.msg('fail');
            }
        });
    });
}
/*点击获取验证码*/
function setsecend(obj, secend) {
    var $me = this;
    $me.get = obj;
    $me.secend = secend;
    $me.num = secend;
    $me.getcode = function (get, num) {
        $me.get.html(num);
        $me.timer = setInterval(function () {
            $me.time();
        }, 1000);

    }
    //定义秒数
    $me.time = function () {
        $me.num = $me.num - 1;
        $me.t = $me.num;
        if ($me.t > 0) {
            $me.get.html($me.t);
        } else {
            clearInterval($me.timer);
            window.location.href = "/Admin/Public/login.html";
        }
    }
    $me.getcode($me.get, $me.num);
}
/*点击获取验证码*/
/*多选*/
function checkbox(that) {
    var obj = $(that);
    var objid = obj.data("bind");
    var objname = obj.data("name");
    var valname = $("#iframe-src").contents().find("#zpname").val().split(",");
    var valid = $("#iframe-src").contents().find("#zhipai").val().split(",");
    if (obj.hasClass("checked")) {
        obj.removeClass("checked");
        if (valid.indexOf("" + objid + "") >= 0) {//id存在value里
            $.each(valid, function (index, item) {
                // index是索引值（即下标）   item是每次遍历得到的值；
                if (item == objid) {
                    valid.splice(index, 1);
                }
            });
            $.each(valname, function (index, item) {
                // index是索引值（即下标）   item是每次遍历得到的值；
                if (item == objname) {
                    valname.splice(index, 1);
                }
            });
            if (valid[0] == "") {
                valid.splice(0, 1);
            }
            if (valname[0] == "") {
                valname.splice(0, 1);
            }
            $("#iframe-src").contents().find("#zhipai").val(valid);
            $("#iframe-src").contents().find("#zpname").val(valname);
        } else {
            valid.push(objid);//往数组末尾添加一个字符a
            valname.push(objname);
            if (valid[0] == "") {
                valid.splice(0, 1);
            }
            if (valname[0] == "") {
                valname.splice(0, 1);
            }
            $("#iframe-src").contents().find("#zhipai").val(valid);
            $("#iframe-src").contents().find("#zpname").val(valname);
        }
    } else {
        obj.addClass("checked");
        if (valid.indexOf("" + objid + "") >= 0) {//id存在value里
            return false;
        } else {
            valid.push(objid);//往数组末尾添加一个字符a
            valname.push(objname);
            if (valid[0] == "") {
                valid.splice(0, 1);
            }
            if (valname[0] == "") {
                valname.splice(0, 1);
            }
            $("#iframe-src").contents().find("#zhipai").val(valid);
            $("#iframe-src").contents().find("#zpname").val(valname);
        }
    }
}
function iszp(that) {
	$("tbody").html();
    var th = $(that);
    var url = th.data("url");
    $.ajax({
        type: "get",
        url: url,
        success: function (data) {
        	console.log(data);
            var list = eval(data);
            var objid = list.list;
            var html = "";
            for (i = 0; i < objid.length; i++) {
                html += '<tr><td style="width:100px;"><div onclick="checkbox(this);" class="icheckbox_square-aero" data-bind="' + objid[i].uid + '" data-name="' + objid[i].username + '"></div></td><td style="width:120px;">' + objid[i].username + '</td><td>' + objid[i].mobile + '</td><td class="isaddress" style="width:225px;" title="' + objid[i].address + '"> ' + objid[i].address + '</td><td class="iswork" data-work="' + objid[i].is_work + '"></td></tr>'
            }
            var objth = th.parent();
            objth.prev(".table-responsive").find("tbody").html(html);
            $(".iswork").each(function () {
                var obj = $(this);
                if (obj.data("work") == 0||obj.data("work")==null||obj.data("work")==3) {
                    obj.html('<span class="label label-success">没有任务</span>');
                } else {
                    obj.html('<span class="label label-danger">已有任务</span>');
                    obj.parents("tr").find(".icheckbox_square-aero").remove();
                }
            });
            if (th.html() == objth.find("span").eq(0).html()) {
                if (list.curren == 1) {
                    objth.find("span").eq(0).data("url", "/Admin/company/get_users/p/" + list.curren + "").html("首页");
                    objth.find("span").eq(1).data("url", "/Admin/company/get_users/p/" + (list.curren - 0 + 1) + "").html("下一页");
                } else {
                    objth.find("span").eq(0).data("url", "/Admin/company/get_users/p/" + (list.curren - 0 - 1) + "").html("上一页");
                    objth.find("span").eq(1).data("url", "/Admin/company/get_users/p/" + (list.curren) + "").html("下一页");
                }
            } else {
                if (list.curren == list.pagenum) {
                    objth.find("span").eq(0).data("url", "/Admin/company/get_users/p/" + (list.curren - 0 - 1) + "").html("上一页");
                    objth.find("span").eq(1).data("url", "/Admin/company/get_users/p/" + list.curren + "").html("末页");
                } else {
                    objth.find("span").eq(0).data("url", "/Admin/company/get_users/p/" + list.curren + "").html("上一页");
                    objth.find("span").eq(1).data("url", "/Admin/company/get_users/p/" + (list.curren - 0 + 1) + "").html("下一页");
                }
            }
        },
        error: function () {},
    });
}

